package com.sanery.ui.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sanery.entity.Food;
import com.sanery.service.FoodService;

@Controller
public class FoodController {
	@Resource(name = "foodService")
	private FoodService service = null;

	@RequestMapping(value = "/deleteFood", method = RequestMethod.GET)
	@ResponseBody
	public String deleteFood(Integer id) {
		Integer count = service.deleteFood(id);
		return "{\"count\":" + count + "}";
	}

	@RequestMapping(value = "/list")
	@ResponseBody
	public List<Food> list() {
		List<Food> list = service.getList();
		return list;
	}

	@RequestMapping(value = "/updateFood")
	@ResponseBody
	public String updateFood(Integer shop_id, String food_name, Float food_price, Integer food_id) {
		int count = service.updateFood(shop_id, food_name, food_price, food_id);
		return "{\"count\":" + count + "}";
	}

	@RequestMapping(value = "/addFood")
	@ResponseBody
	public String addFood(Integer shop_id, String food_name, Float food_price) {
		int count = service.addFood(shop_id, food_name, food_price);
		return "{\"count\":" + count + "}";
	}

	@RequestMapping("/selUpdateList")
	@ResponseBody
	public List<Food> selUpdateList(Integer type_id, Integer shop_id) {
		List<Food> list = service.selUpdateList(type_id, shop_id);
		return list;
	}

}
